local shichou = fk.CreateSkill {
  name = "gai__shichou",
}

Fk:loadTranslationTable{
  ["gai__shichou"] = "誓仇",
  [":gai__shichou"] = "出牌阶段，你可以将一张牌当【杀】使用。每种颜色每回合各限一次，且必须指定同一个目标。",

  ["#gai__shichou"] = "誓仇：将一张牌当【杀】使用",

  ["$gai__shichou1"] = "你们一个都别想跑！",
  ["$gai__shichou2"] = "新仇旧恨，一并结算！",
}

shichou:addEffect("active", {
  anim_type = "offensive",
  prompt = "#gai__shichou",
  card_num = 1,
  target_num = 1,
  can_use = function(self, player)
    return #player:getTableMark("gai__shichou-turn") < 2
  end,
  handly_pile = true,
  card_filter = function(self, player, to_select, selected)
    if #selected == 0 then
      local color = Fk:getCardById(to_select).color
      if color == Card.NoColor or table.contains(player:getTableMark("gai__shichou-turn"), color) then return end
      local card = Fk:cloneCard("slash")
      card.skillName = shichou.name
      card:addSubcard(to_select)
      return not player:prohibitUse(card)
    end
  end,
  target_filter = function(self, player, to_select, selected, selected_cards)
    if #selected > 0 or to_select == player then return end
    local card = Fk:cloneCard("slash")
    card.skillName = shichou.name
    card:addSubcards(selected_cards)
    if player:canUseTo(card, to_select) then
      if player:getMark("gai__shichou_to-turn") == 0 then
        return true
      else
        return to_select.id == player:getMark("gai__shichou_to-turn")
      end
    end
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    room:addTableMark(player, "gai__shichou-turn", Fk:getCardById(effect.cards[1]).color)
    room:setPlayerMark(player, "gai__shichou_to-turn", effect.tos[1].id)
    local card = Fk:cloneCard("slash")
    card:addSubcards(effect.cards)
    card.skillName = shichou.name
    local use = {
      from = player,
      tos = effect.tos,
      card = card,
    }
    room:useCard(use)
  end,
})

return shichou
